package jocode;

import processing.core.*;
import processing.opengl.*;

public class JOBridgeP5 {
    
    public static JOApp init(PApplet p) {
        try {
            JOApp.gl = ((PGraphicsOpenGL)p.g).gl;
            JOApp.glu = ((PGraphicsOpenGL)p.g).glu;
        } catch (ClassCastException _e) {
            System.err.println("You must render with OpenGL when using the JOApp library!");
            _e.printStackTrace();
            //System.exit(1);
        }
        
        JOApp app = new JOApp("JOCode Application", p.width, p.height);
        
        JOApp.viewportX = 0;
        JOApp.viewportY = 0;
        JOApp.viewportW = JOApp.displayWidth;
        JOApp.viewportH = JOApp.displayHeight;
        
        JOApp.dataPrefix = p.dataPath("");
        
        JOApp.msg("JOP5.init() dataPrefix=" + JOApp.dataPrefix);
        
        return app; 
    }
}
